Skip to contentSkip to conversation

Change in openvpn[master]: Fix FreeBSD-DCO and Multisocket interaction

Openvpn-devel In review its_Giaan (Code Review) 2 participants 7 messages Mar 28, 2025 – Apr 2, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1743175587000.I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/925?usp=email

to review the following change.

Change subject: Fix FreeBSD-DCO and Multisocket interaction
......................................................................

Fix FreeBSD-DCO and Multisocket interaction

FreeBSD-DCO does not support TCP as transport
protocol so in order to be able to use DCO in a
multi-socket environment we need to check
the local_list entries and disable DCO
if any of the listening socket is TCP.

While at it, removed some dead code left
from Multisocket polishing.

Github: #710

Change-Id I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf

---
M src/openvpn/dco.c
M src/openvpn/options.c
M src/openvpn/options.h

3 files changed, 9 insertions(+), 22 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/25/925/1

src/openvpn/dco.c +9 -3
index d00958d..7ad9cb3 100644
@@ -260,10 +260,16 @@
     }
 
 #if defined(TARGET_FREEBSD)
-    if (!proto_is_udp(ce->proto))
+    if (ce->local_list)
     {
-        msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
-        return false;
+        for (int i = 0; i < ce->local_list->len; i++)
+        {
+            if (!proto_is_dgram(ce->local_list->array[i]->proto))
+            {
+                msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
+                return false;
+            }
+        }
     }
 #endif
 
src/openvpn/options.c +0 -17
index 99dd60a..6605a42 100644
@@ -9577,20 +9577,3 @@
 
     return false;
 }
-
-bool
-has_tcp_in_local_list(const struct options *options)
-{
-    if (options->ce.local_list)
-    {
-        for (int i = 0; i < options->ce.local_list->len; i++)
-        {
-            if (!proto_is_dgram(options->ce.local_list->array[i]->proto))
-            {
-                return true;
-            }
-        }
-    }
-
-    return false;
-}
src/openvpn/options.h +0 -2
index fa617c8..8d1ef6c 100644
@@ -921,8 +921,6 @@
 
 bool has_udp_in_local_list(const struct options *options);
 
-bool has_tcp_in_local_list(const struct options *options);
-
 /**
  * Returns whether the current configuration has dco enabled.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/925?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf
Gerrit-Change-Number: 925
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, its_Giaan, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/925?usp=email )

Change subject: Fix FreeBSD-DCO and Multisocket interaction
......................................................................

Patch Set 1:

(3 comments)

Patchset:

PS1:
questions...

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/925/comment/9d655d2e_4fc29dc7 :
PS1, Line 263: if (ce->local_list)
will this also catch clients that have no --local at all, just --remote ... tcp? FreeBSD DCO also needs to be disabled for TCP clients.

http://gerrit.openvpn.net/c/openvpn/+/925/comment/95331584_9525203f :
PS1, Line 277: if (!proto_is_udp(ce->proto) && mode == MODE_SERVER)
this looks as if we need the fix for windows too... maybe keep & use the has_tcp_in_local_list() for this?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/925?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf
Gerrit-Change-Number: 925
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 28 Mar 2025 21:34:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, its_Giaan, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/925?usp=email )

Change subject: Fix FreeBSD-DCO and Multisocket interaction
......................................................................

Patch Set 1: Code-Review+2

(3 comments)

Patchset:

PS1:
seems windows does not need it (because we currently support only 1 socket for server && DCO, so the 1 socket-check works) - so let's proceed this.

File src/openvpn/dco.c:

http://gerrit.openvpn.net/c/openvpn/+/925/comment/b1c9e52b_61c0c566 :
PS1, Line 263: if (ce->local_list)

Quoted 1 line

will this also catch clients that have no --local at all, just `--remote ... […]

Done

http://gerrit.openvpn.net/c/openvpn/+/925/comment/b50916b0_8d184b77 :
PS1, Line 277: if (!proto_is_udp(ce->proto) && mode == MODE_SERVER)

Quoted 1 line

this looks as if we need the fix for windows too... […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/925?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf
Gerrit-Change-Number: 925
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 02 Apr 2025 13:20:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment

#4 lore raw

PATCH 1/1 Fix FreeBSD-DCO and Multisocket interaction

In reply to a message not in the archive

From: Gianmarco De Gregori <[email protected]...>

FreeBSD-DCO does not support TCP as transport protocol so in order to be able to use DCO in a multi-socket environment we need to check the local_list entries and disable DCO if any of the listening socket is TCP.

While at it, removed some dead code left from Multisocket polishing.

Github: closes OpenVPN/openvpn#710

Change-Id I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/925
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/dco.c +9 -3
index d00958d..7ad9cb3 100644
@@ -260,10 +260,16 @@
     }
 
 #if defined(TARGET_FREEBSD)
-    if (!proto_is_udp(ce->proto))
+    if (ce->local_list)
     {
-        msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
-        return false;
+        for (int i = 0; i < ce->local_list->len; i++)
+        {
+            if (!proto_is_dgram(ce->local_list->array[i]->proto))
+            {
+                msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
+                return false;
+            }
+        }
     }
 #endif
 
src/openvpn/options.c +0 -17
index 99dd60a..6605a42 100644
@@ -9577,20 +9577,3 @@
 
     return false;
 }
-
-bool
-has_tcp_in_local_list(const struct options *options)
-{
-    if (options->ce.local_list)
-    {
-        for (int i = 0; i < options->ce.local_list->len; i++)
-        {
-            if (!proto_is_dgram(options->ce.local_list->array[i]->proto))
-            {
-                return true;
-            }
-        }
-    }
-
-    return false;
-}
src/openvpn/options.h +0 -2
index fa617c8..8d1ef6c 100644
@@ -921,8 +921,6 @@
 
 bool has_udp_in_local_list(const struct options *options);
 
-bool has_tcp_in_local_list(const struct options *options);
-
 /**
  * Returns whether the current configuration has dco enabled.
  */
#5 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix FreeBSD-DCO and Multisocket interaction

Thanks for fixing this. Stared at the code, discussed a bit, and actually went out and tested (on FreeBSD 14 server test set). Without the patch an instance with both UDP and TCP starts with DCO and dies miserably when a TCP connection comes in - with the patch, it will disable DCO, and do UDP+TCP in userland (kernel doesn't do TCP, so there is nothing we can do). With multiple UDP sockets, DCO works.

Your patch has been applied to the master branch.

commit a061b3a94c5489a2f207189343f1c235e8181b87

Author: Gianmarco De Gregori
Date:   Wed Apr 2 15:21:42 2025 +0200
     Fix FreeBSD-DCO and Multisocket interaction

     Signed-off-by: Gianmarco De Gregori <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg31324.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#6 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/925?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Fix FreeBSD-DCO and Multisocket interaction
......................................................................

Fix FreeBSD-DCO and Multisocket interaction

FreeBSD-DCO does not support TCP as transport protocol so in order to be able to use DCO in a multi-socket environment we need to check the local_list entries and disable DCO if any of the listening socket is TCP.

While at it, removed some dead code left from Multisocket polishing.

Github: closes OpenVPN/openvpn#710

Change-Id I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31324.html

---
M src/openvpn/dco.c
M src/openvpn/options.c
M src/openvpn/options.h

3 files changed, 9 insertions(+), 22 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/25/925/2

src/openvpn/dco.c +9 -3
index d00958d..7ad9cb3 100644
@@ -260,10 +260,16 @@
     }
 
 #if defined(TARGET_FREEBSD)
-    if (!proto_is_udp(ce->proto))
+    if (ce->local_list)
     {
-        msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
-        return false;
+        for (int i = 0; i < ce->local_list->len; i++)
+        {
+            if (!proto_is_dgram(ce->local_list->array[i]->proto))
+            {
+                msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
+                return false;
+            }
+        }
     }
 #endif
 
src/openvpn/options.c +0 -17
index 99dd60a..6605a42 100644
@@ -9577,20 +9577,3 @@
 
     return false;
 }
-
-bool
-has_tcp_in_local_list(const struct options *options)
-{
-    if (options->ce.local_list)
-    {
-        for (int i = 0; i < options->ce.local_list->len; i++)
-        {
-            if (!proto_is_dgram(options->ce.local_list->array[i]->proto))
-            {
-                return true;
-            }
-        }
-    }
-
-    return false;
-}
src/openvpn/options.h +0 -2
index fa617c8..8d1ef6c 100644
@@ -921,8 +921,6 @@
 
 bool has_udp_in_local_list(const struct options *options);
 
-bool has_tcp_in_local_list(const struct options *options);
-
 /**
  * Returns whether the current configuration has dco enabled.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/925?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf
Gerrit-Change-Number: 925
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#7 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/925?usp=email )

Change subject: Fix FreeBSD-DCO and Multisocket interaction
......................................................................

Fix FreeBSD-DCO and Multisocket interaction

FreeBSD-DCO does not support TCP as transport protocol so in order to be able to use DCO in a multi-socket environment we need to check the local_list entries and disable DCO if any of the listening socket is TCP.

While at it, removed some dead code left from Multisocket polishing.

Github: closes OpenVPN/openvpn#710

Change-Id I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31324.html

---
M src/openvpn/dco.c
M src/openvpn/options.c
M src/openvpn/options.h

3 files changed, 9 insertions(+), 22 deletions(-)
src/openvpn/dco.c +9 -3
index d00958d..7ad9cb3 100644
@@ -260,10 +260,16 @@
     }
 
 #if defined(TARGET_FREEBSD)
-    if (!proto_is_udp(ce->proto))
+    if (ce->local_list)
     {
-        msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
-        return false;
+        for (int i = 0; i < ce->local_list->len; i++)
+        {
+            if (!proto_is_dgram(ce->local_list->array[i]->proto))
+            {
+                msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
+                return false;
+            }
+        }
     }
 #endif
 
src/openvpn/options.c +0 -17
index 99dd60a..6605a42 100644
@@ -9577,20 +9577,3 @@
 
     return false;
 }
-
-bool
-has_tcp_in_local_list(const struct options *options)
-{
-    if (options->ce.local_list)
-    {
-        for (int i = 0; i < options->ce.local_list->len; i++)
-        {
-            if (!proto_is_dgram(options->ce.local_list->array[i]->proto))
-            {
-                return true;
-            }
-        }
-    }
-
-    return false;
-}
src/openvpn/options.h +0 -2
index fa617c8..8d1ef6c 100644
@@ -921,8 +921,6 @@
 
 bool has_udp_in_local_list(const struct options *options);
 
-bool has_tcp_in_local_list(const struct options *options);
-
 /**
  * Returns whether the current configuration has dco enabled.
  */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/925?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf
Gerrit-Change-Number: 925
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged